package yh;

/**
 * @Author:云尚
 * @Description:
 */
public class User {
    //1.私有属性
    private String name;
    private int age;
    //2.公有方法
    public void setName(String name) {
        this.name = name;
    }
    public void setAge(int age) {
        if(age>0&& age<300) {
            this.age = age;
        } else {
            System.out.println("年龄设置错误，年龄设置失败");
        }

    }
    public String getName() {
        return this.name;
    }
    public int getAge() {
        return this.age;
    }
}



